﻿using Mail_Box_Net_Disk.PublicTools;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI;
using Windows.UI.ViewManagement;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;

// https://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x804 上介绍了“空白页”项模板

namespace Mail_Box_Net_Disk
{
    /// <summary>
    /// 可用于自身或导航至 Frame 内部的空白页。
    /// </summary>
    public sealed partial class MainPage : Page
    {
        public MainPage()
        {
            this.InitializeComponent();
        }

        private async void Page_Loaded(object sender, RoutedEventArgs e)
        {
            StartFrame.Navigate(typeof(Start));
            UploadingFrame.Navigate(typeof(Uploading));
            CompleteFrame.Navigate(typeof(Complete));
            FileListFrame.Navigate(typeof(FileList));
            SettingFrame.Navigate(typeof(Settings));
            NoticeFrame.Navigate(typeof(Notice));
            //加载页面

            if (Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.UI.ViewManagement.StatusBar"))
            {
                StatusBar statusBar = StatusBar.GetForCurrentView();
                statusBar.BackgroundColor = Color.FromArgb(255, 255, 255, 255);
                statusBar.ForegroundColor = Color.FromArgb(255, 0, 0, 0);
                statusBar.BackgroundOpacity = 1;
            }//手机状态栏颜色


            string version = (string)FileRW.GetValue("version"); //检查版本，用于显示更新信息
            if (version == null || version != "0")
            {
                FileRW.SetValue("version", "0");
                await Tools.ShowMessageDialog("提示","第一次打开");
            }
            
            if (FileRW.GetValue("IMAPServer") != null)
            {
                smtp.IMAPServer = (string)FileRW.GetValue("IMAPServer");
            }
            if (FileRW.GetValue("SMTPServer") != null)
            {
                smtp.SMTPServer = (string)FileRW.GetValue("SMTPServer");
            }
            if (FileRW.GetValue("IMAPPort") != null)
            {
                smtp.IMAPPort = (int)FileRW.GetValue("IMAPPort");
            }
            if (FileRW.GetValue("SMTPPort") != null)
            {
                smtp.SMTPPort = (int)FileRW.GetValue("SMTPPort");
            }
            if (FileRW.GetValue("account") != null)
            {
                smtp.account = (string)FileRW.GetValue("account");
            }
            if (FileRW.GetValue("password") != null)
            {
                smtp.password = (string)FileRW.GetValue("password");
            }
            if (FileRW.GetValue("isSSL") != null)
            {
                smtp.isSSL = (bool)FileRW.GetValue("isSSL");
            }
            if (FileRW.GetValue("fileSplit") != null)
            {
                smtp.fileSplit = (int)FileRW.GetValue("fileSplit");
            }

        }
    }
}
